package com.xy.submit.configs;


import com.xy.submit.annotations.ExcludeRepeatSubmit;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;

import java.util.function.Predicate;

public class ExceptionImportSelector implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {

        AnnotationAttributes attributes = AnnotationAttributes.fromMap(annotationMetadata
                .getAnnotationAttributes(ExcludeRepeatSubmit.class.getName()));

        assert attributes != null;
        //PreventStrategy result = attributes.getEnum("bol");
        String preventRepeatClassName = PreventRepeatConfig.class.getName();
        return new String[]{preventRepeatClassName};
    }

    @Override
    public Predicate<String> getExclusionFilter() {
        return ImportSelector.super.getExclusionFilter();
    }



}
